package com.bw.zuoye0722

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.base.mvvm.BaseViewActivity
import com.bw.zuoye0722.adapter.FragmentAdapter
import com.bw.zuoye0722.adapter.MyTab
import com.bw.zuoye0722.databinding.ActivityWelComeBinding
import com.bw.zuoye0722.fragment.welcome.BlankFragmentOne
import com.bw.zuoye0722.fragment.welcome.BlankFragmentThree
import com.bw.zuoye0722.fragment.welcome.BlankFragmentTwo
import com.flyco.tablayout.listener.CustomTabEntity
import com.flyco.tablayout.listener.OnTabSelectListener

class WelComeActivity :BaseViewActivity<ActivityWelComeBinding>() {
    private lateinit var fragmentAdapter: FragmentAdapter
    var list= mutableListOf<Fragment>()
    var listTab:ArrayList<CustomTabEntity> = arrayListOf()
    override fun initView() {
        list.add(BlankFragmentOne())
        list.add(BlankFragmentTwo())
        list.add(BlankFragmentThree())
        fragmentAdapter=FragmentAdapter(this,list)
        binding.vp2.adapter=fragmentAdapter
        listTab.add(MyTab("",R.drawable.baseline_circle_24,R.drawable.baseline_circle))
        listTab.add(MyTab("",R.drawable.baseline_circle_24,R.drawable.baseline_circle))
        listTab.add(MyTab("",R.drawable.baseline_circle_24,R.drawable.baseline_circle))
        binding.tab.setTabData(listTab)
        binding.vp2.registerOnPageChangeCallback(object :OnPageChangeCallback(){
            override fun onPageSelected(position: Int) {
                super.onPageSelected(position)
                binding.tab.currentTab=position
            }
        })
        binding.tab.setOnTabSelectListener(object :OnTabSelectListener{
            override fun onTabSelect(position: Int) {
                binding.vp2.currentItem=position
            }

            override fun onTabReselect(position: Int) {

            }

        })
        //点击跳过进去登录页
        binding.next.setOnClickListener {
            ARouter.getInstance().build("/app/login/LoginActivity").navigation()
        }
    }

    override fun initData() {

    }

    override fun getLayoutId(): Int {
        return R.layout.activity_wel_come
    }
}